$(function () {
    initSysCount();
    initChartLogVisit();
    initChartLoginHour();
});


function initSysCount() {
    var url = '/manage/index/syscount';
    Base.ajax({
        url: url,
        success: function (data) {
            if (data.code) {
                $("#userCount").html(data.data.userCount);
                $("#roleCount").html(data.data.roleCount);
                $("#funcCount").html(data.data.funcCount);
                $("#noticeCount").html(data.data.noticeCount);
                $("#logVisitCount").html(data.data.logVisitCount);
                $("#logOperCount").html(data.data.logOperCount);
            } else {
                tiperror("查询系统统计信息失败！");
            }
        }
    });
}

function initChartLogVisit() {
    var url = '/manage/index/logvisittrend';
    Base.ajax({
        url: url,
        success: function (data) {
            if (data.code) {
                var option = {
                    tooltip: {},
                    xAxis: {
                        data: []
                    },
                    yAxis: {},
                    series: [{
                        type: 'line',
                        data: []
                    },{
                        type: 'bar',
                        barMaxWidth: 20,
                        data: []
                    }]
                };

                option.xAxis.data = data.data.x;
                option.series[0].data = data.data.y;
                option.series[1].data = data.data.y;

                EchartsUtil.bar("chartLogVisit", option);
            } else {
                tiperror("查询访问趋势数据失败！");
            }
        }
    });
}

function initChartLoginHour() {
    var url = '/manage/index/loginhour';
    Base.ajax({
        url: url,
        success: function (data) {
            if (data.code) {
                var option = {
                    tooltip: {},
                    xAxis: {
                        data: []
                    },
                    yAxis: {},
                    series: [{
                        type: 'bar',
                        data: []
                    }]
                };

                option.xAxis.data = data.data.x;
                option.series[0].data = data.data.y;

                EchartsUtil.bar("chartLoginHour", option);
            } else {
                tiperror("查询登录时段数据失败！");
            }
        }
    });
}
